﻿#region License
// (c) Intergen.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using MediaWiki.Office.Model.Utilities;

namespace MediaWiki.Office.Model
{
  public class Font
  {
    private string _name;
    private List<string> _alternateNames = new List<string>();
    private FontFamily? _family;

    public FontFamily? Family
    {
      get { return _family; }
      set { _family = value; }
    }

    public List<string> AlternateNames
    {
      get { return _alternateNames; }
      set { _alternateNames = value; }
    }

    public string Name
    {
      get { return _name; }
      set { _name = value; }
    }

    public Font(XElement element)
    {
      if (element == null)
        throw new ArgumentNullException("element");

      XNamespace ns = element.Name.Namespace;

      _name = (string)element.Attribute(ns + "name");

      string altNames = XmlUtils.GetValue(element.Element(ns + "altName"));
      if (!string.IsNullOrEmpty(altNames))
        _alternateNames.AddRange(altNames.Split(new char[] {','}));

      _family = XmlUtils.GetValue<FontFamily>(element.Element(ns + "family"));
    }
  }
}